[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 atexit()                Register Exit Function

 #include   <stdlib.h>

 int        atexit(func);
 atexit_t   func;                        Function to be called

    atexit() identifies a function as an "exit function."  The function
    is pointed to by 'func', and 'func' is a pointer of type 'atexit_t'
    (defined in <stdlib.h>).

    Up to 32 exit functions can be registered. Each requires a separate
    call to atexit(). If the program terminates normally, exit() calls
    'func' just before returning control to the operating system, and the
    exit functions are carried out on a last in, first out basis.

    Returns:    0, if successful.  If there is no remaining space for
                registering functions, a non-zero value is returned.


   -------------------------------- Example ---------------------------------

           #include <stdlib.h>

           void goodbye()
           {
               printf("Goodbye ");
           }

           void world()
           {
               printf("world!");
           }

           main()
           {
               atexit(world);
               atexit(goodbye);
               printf("Hello world.\n");
           }


See Also: exec...() exit() spawn...()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson